package company.dj_F;

import java.util.Scanner;

public class DaJ2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int money = sc.nextInt();
        // 价格
        int[] v = new int[n];
        //满意度
        int[] i = new int[n];
        // 数量
        int[] c = new int[n];
        for (int j = 0; j < n; j++) {
            v[j] = sc.nextInt();
            i[j] = sc.nextInt();
            c[j] = sc.nextInt();
        }
        int[][] dp = new int[n + 1][money + 1];
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= money; k++) {
                //钱不够
                if (k < v[j - 1]) {
                    dp[j][k] = dp[j - 1][k];
                } else {
                    int min = Math.min(k / v[j - 1], c[j - 1]);
                    int max = 0;
                    for (int l = 0; l <= min; l++) {
                        max = Math.max(max, dp[j - 1][k - v[j - 1] * l] + i[j - 1] * l);
                    }
                    dp[j][k] = max;
                }
            }
        }
        System.out.println(dp[n][money]);
    }
}
